﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

using NUnit.Framework;

using LowLevelGraphics;
using LowLevelGraphics.Extractors;

namespace UnitTests
{
    [TestFixture]
    public class AutoCropTest
    {
        private UnsafeBitmap m_Bitmap = null;

        [SetUp]
        public void SetUp()
        {
            Bitmap newBitmap = new Bitmap(100, 100);

            int nPenWidth = 20;
            Graphics g = Graphics.FromImage(newBitmap);
            g.DrawRectangle(new Pen(Brushes.Black, nPenWidth), new Rectangle(0, 0, 100, 100));
            m_Bitmap = newBitmap;
            int nWidth = m_Bitmap.Width;
            int nHeight = m_Bitmap.Height;

            int y = 0;
            int x = 0;
            Random random = new Random(DateTime.Now.Millisecond * this.GetHashCode());
            for (y = nPenWidth; y < nHeight - nPenWidth; y++)
            {
                for (x = nPenWidth; x < nWidth - nPenWidth; x++)
                {
                    Color color = Color.FromArgb(random.Next(0, 16777215));
                    color = Color.FromArgb(255, color.R, color.G, color.B);
                    m_Bitmap.SetPixel(x, y, color);
                }
            }
        }

        [Test]
        public void TestAutoCrop()
        {
            AutoCrop crop = new AutoCrop();
            crop.Crop(m_Bitmap);
        }

        [TearDown]
        public void TearDown()
        { 
        }
    }
}
